package com.itcast.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itcast.health.pojo.*;
import com.itcast.service.OrderListService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Song
 * @version: V1.0
 * @date: 2019/12/3 11:09
 * @description: com.itcast.controller
 */

@RestController
@RequestMapping("/checkOrderList")
public class OrderController {

    @Reference
    OrderListService orderListService;

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return orderListService.findPage(queryPageBean);
    }

    @RequestMapping("/add")
    public Result submit(@RequestBody OrderInfoVo orderInfoVo) {
        //调用这个接口默认就是电话预约
        orderInfoVo.setOrderType(Order.ORDERTYPE_TELEPHONE);
        //調用dubbo服務創建訂單
        return orderListService.add(orderInfoVo);

    }

    @RequestMapping("/findAll")
    public Result findAll(){
        //查询所有的套餐
        List<Setmeal> setmels = orderListService.findAll();
        //一定要返回
        return Result.success("",setmels);
    }

}
